#include <ctype.h>
#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

/**
 * Definition for a binary tree node.
 */
struct TreeNode {
	int val;
	struct TreeNode* left;
	struct TreeNode* right;
};
typedef struct TreeNode treeNode, *treenode;

bool isBalanced(struct TreeNode* root);
int height(treenode root);

int main()
{
	return 0;
}

bool isBalanced(struct TreeNode* root)
{
	return height(root) >= 0;
}

int height(treenode root)
{
	if (!root) return 0;
	int leftH = height(root->left);
	int rightH = height(root->right);
	if (leftH == -1 || rightH == -1 || abs(leftH - rightH) > 1)
		return -1;
	else
		return fmax(leftH, rightH) + 1;
}
